package com.huazi.www.dept.service.impl;
/**
 * User: 王有为
 * Date: 2021/5/7
 * Time: 16：56
 */


import com.huazi.www.dept.dao.DepartmentDao;
import com.huazi.www.dept.dao.impl.DepartmentDaoImpl;
import com.huazi.www.dept.entity.Department;
import com.huazi.www.dept.entity.Department_CT;
import com.huazi.www.dept.service.DepartmentServie;
import com.huazi.www.dept.util.Page;

import java.util.List;

public class DepartmentServieImpl implements DepartmentServie {
    DepartmentDao departmentDao = new DepartmentDaoImpl();

    /**
     * 查询准备拍照的页码
     * @param userName  患者名字
     * @param currentPage   页码
     * @return
     */
    @Override
    public Page<Department> page(String userName, Integer currentPage) {
        Page<Department> page = new Page<>();   //创建新的对象
        page.setPageSize(8);    //设置显示的行数
        page.setCurrentPage(currentPage);      //设置页码
        Integer totalCount = departmentDao.count(userName);  //调用dao层总记录数
        page.setTotalCount(totalCount);   //设置总记录数
        Integer statr = (page.getCurrentPage() - 1) * page.getPageSize();   //下标
        List<Department> list = departmentDao.list(userName, statr, page.getPageSize());    //调用dao层分页查询方法
        page.setList(list); //赋值给对象
        return page;    //分会对象
    }

    /**
     * 查询已经拍照的用户进行分页
     * @param name  姓名
     * @param currentPage   页码
     * @return
     */
    @Override
    public Page<Department> pagepaiz(String name, Integer currentPage) {
        Page<Department> page = new Page<>();   //创建新的对象
        page.setPageSize(8);    //设置显示的行数
        page.setCurrentPage(currentPage);      //设置页码
        Integer totalCount = departmentDao.countr(name);  //调用dao层总记录数
        page.setTotalCount(totalCount);   //设置总记录数
        Integer statr = (page.getCurrentPage() - 1) * page.getPageSize();   //下标
        List<Department> list = departmentDao.lis(name, statr, page.getPageSize());    //调用dao层分页查询方法
        page.setList(list); //赋值给对象
        return page;    //返回对象
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Override
    public Department departmer(Integer id) {
        return departmentDao.departmer(id);
    }

    /**
     * 根据id修改
     * @param userid    编号
     * @param state 排队号
     * @return
     */
    @Override
    public boolean modify(Integer userid, Integer state) {
        Integer modify = departmentDao.modify(userid, state);
        if (modify > 0) {
            return true;
        }
        return false;
    }

    /**
     * 新增CT记录
     */
    @Override
    public boolean insertCt(Department_CT ct) {
        int i = departmentDao.insertCt(ct);
        if (i == 1) {
            return true;
        }
        return false;
    }


}
